/**
 * Created on 20 nov. 2011 at 20:23:36 by HozakaN
 */
package fr.castorhoz.isi_connectivity_widget.widget_configuration;

import java.util.Observable;

import android.view.View;
import android.view.View.OnClickListener;
import fr.castorhoz.isi_connectivity_widget.widget_configuration.custom_adapters.WidgetLineHolder;


/**
 * @author HozakaN
 *
 */
public class WidgetConfigurationLineClickedListener extends Observable implements OnClickListener {
	
	/* (non-Javadoc)
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	public void onClick(View v) {
		WidgetLineHolder holder = (WidgetLineHolder) v.getTag();
		String elem = holder.textView.getText().toString();
		if (holder.checkbox.isChecked()) {
			holder.checkbox.setChecked(false);
			setChanged();
			notifyObservers(new String[] {WidgetConfiguration.REMOVE_WIDGET, elem});
		} else {
			holder.checkbox.setChecked(true);
			setChanged();
			notifyObservers(new String[] {WidgetConfiguration.ADD_WIDGET, elem});
		}
	}

}
